using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class ItemPurReqDetailInfo
    {
		#region Local Variable
		public enum Field
		{
			DTB,
			RequestRef,
			DetailNo,
			ItemCode,
			ItemDescription,
			PartNo,
			Unit,
			Quantity,
			Remark
		}
		private String _DTB;
		private String _RequestRef;
		private Int32 _DetailNo;
		private String _ItemCode;
		private String _ItemDescription;
		private String _PartNo;
		private String _Unit;
		private Double _Quantity;
		private String _Remark;
		
		public String DTB{	get{ return _DTB;} set{_DTB = value;} }
		public String RequestRef{	get{ return _RequestRef;} set{_RequestRef = value;} }
		public Int32 DetailNo{	get{ return _DetailNo;} set{_DetailNo = value;} }
		public String ItemCode{	get{ return _ItemCode;} set{_ItemCode = value;} }
		public String ItemDescription{	get{ return _ItemDescription;} set{_ItemDescription = value;} }
		public String PartNo{	get{ return _PartNo;} set{_PartNo = value;} }
		public String Unit{	get{ return _Unit;} set{_Unit = value;} }
		public Double Quantity{	get{ return _Quantity;} set{_Quantity = value;} }
		public String Remark{	get{ return _Remark;} set{_Remark = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public ItemPurReqDetailInfo()
		{
			_DTB = "";
			_RequestRef = "";
			_DetailNo = 0;
			_ItemCode = "";
			_ItemDescription = "";
			_PartNo = "";
			_Unit = "";
			_Quantity = 0;
			_Remark = "";
		}
		
		public ItemPurReqDetailInfo(
		String DTB,
		String RequestRef,
		Int32 DetailNo,
		String ItemCode,
		String ItemDescription,
		String PartNo,
		String Unit,
		Double Quantity,
		String Remark
		)
		{
			_DTB = DTB;
			_RequestRef = RequestRef;
			_DetailNo = DetailNo;
			_ItemCode = ItemCode;
			_ItemDescription = ItemDescription;
			_PartNo = PartNo;
			_Unit = Unit;
			_Quantity = Quantity;
			_Remark = Remark;
		}
		public ItemPurReqDetailInfo(DataRow dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_RequestRef = dr[Field.RequestRef.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.RequestRef.ToString()]);
				_DetailNo = dr[Field.DetailNo.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.DetailNo.ToString()]);
				_ItemCode = dr[Field.ItemCode.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ItemCode.ToString()]);
				_ItemDescription = dr[Field.ItemDescription.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ItemDescription.ToString()]);
				_PartNo = dr[Field.PartNo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.PartNo.ToString()]);
				_Unit = dr[Field.Unit.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Unit.ToString()]);
				_Quantity = dr[Field.Quantity.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.Quantity.ToString()]);
				_Remark = dr[Field.Remark.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Remark.ToString()]);
			}
		}
		public ItemPurReqDetailInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_RequestRef = dr[Field.RequestRef.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.RequestRef.ToString()]);
				_DetailNo = dr[Field.DetailNo.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.DetailNo.ToString()]);
				_ItemCode = dr[Field.ItemCode.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ItemCode.ToString()]);
				_ItemDescription = dr[Field.ItemDescription.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ItemDescription.ToString()]);
				_PartNo = dr[Field.PartNo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.PartNo.ToString()]);
				_Unit = dr[Field.Unit.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Unit.ToString()]);
				_Quantity = dr[Field.Quantity.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.Quantity.ToString()]);
				_Remark = dr[Field.Remark.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Remark.ToString()]);
			}
		}
		public ItemPurReqDetailInfo(ItemPurReqDetailInfo objEntr)
		{			
			_DTB = objEntr.DTB;			
			_RequestRef = objEntr.RequestRef;			
			_DetailNo = objEntr.DetailNo;			
			_ItemCode = objEntr.ItemCode;			
			_ItemDescription = objEntr.ItemDescription;			
			_PartNo = objEntr.PartNo;			
			_Unit = objEntr.Unit;			
			_Quantity = objEntr.Quantity;			
			_Remark = objEntr.Remark;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("ItemPurReqDetail");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.DTB.ToString(), typeof(String)),
				new DataColumn(Field.RequestRef.ToString(), typeof(String)),
				new DataColumn(Field.DetailNo.ToString(), typeof(Int32)),
				new DataColumn(Field.ItemCode.ToString(), typeof(String)),
				new DataColumn(Field.ItemDescription.ToString(), typeof(String)),
				new DataColumn(Field.PartNo.ToString(), typeof(String)),
				new DataColumn(Field.Unit.ToString(), typeof(String)),
				new DataColumn(Field.Quantity.ToString(), typeof(Double)),
				new DataColumn(Field.Remark.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.DTB.ToString()] = _DTB;
			row[Field.RequestRef.ToString()] = _RequestRef;
			row[Field.DetailNo.ToString()] = _DetailNo;
			row[Field.ItemCode.ToString()] = _ItemCode;
			row[Field.ItemDescription.ToString()] = _ItemDescription;
			row[Field.PartNo.ToString()] = _PartNo;
			row[Field.Unit.ToString()] = _Unit;
			row[Field.Quantity.ToString()] = _Quantity;
			row[Field.Remark.ToString()] = _Remark;
			return row;
		}
        #endregion InitTable
    }
}
